/*
 * ValidationRule.cpp
 *
 *  Created on: 02/06/2013
 *      Author: Jeffrey Alvarez Masson
 */

#include "ValidationRule.h"
#include "ValidationScope.h"
#include <boost/algorithm/string.hpp>

namespace ValidationRules {

using namespace std;
using namespace boost::algorithm;

std::string ValidationRule::GetRequiredPrecedingRule(std::string preceding)	 {
	vector<string> precedingParts;
	boost::algorithm::split(precedingParts, preceding, is_any_of(","), token_compress_on);
	BOOST_FOREACH(std::string p, precedingParts) {
		trim(p);
		ValidationRule* rule = ValidationRules::ValidationScope::GetCurrent()->GetRule(p);
		if (!rule || rule->GetTimesApplied() == 0)
			return p;
	}
	return "";
}

}


